package com.yuer.tools.myfileziptools.test;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;


public class Solution {

    public static void main(String[] args) throws Exception{
        RandomAccessFile randomAccessFile = new RandomAccessFile("D://abc.txt", "rws");
        randomAccessFile.setLength(300);
        byte[] bytes = new byte[100];
        Arrays.fill(bytes, (byte) 97);
        Thread t = new MyT();
        t.start();
        randomAccessFile.write(bytes, 0, bytes.length);
        randomAccessFile.close();
    }
}

class MyT extends Thread {
    @Override
    public void run() {
        try (
                RandomAccessFile randomAccessFile = new RandomAccessFile("D://abc.txt", "rws")){
            randomAccessFile.setLength(300);
            byte[] bytes2 = new byte[100];
            Arrays.fill(bytes2, (byte) 98);
            randomAccessFile.seek(100);
            randomAccessFile.write(bytes2, 0, bytes2.length);
            randomAccessFile.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}